/*
Copyright (C) 2021-2025 Casa Xu (also Zhiyan Xu) from HIT

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

/*
 * AttMainFunction.c
 *
 *  Created on: 2023年2月16日
 *      Author: 64435
 */



#include "math.h"
//#include "aocs_allh.h"
#include "LOS_SYS.h"

char* debugmsg;

extern SemaphoreHandle_t BinSemphr_MG;

void AttMainFun(uint16_t ModeAcsIn)
{


}

/** @fn void LOS_AOCS_ChangeMode(uint16_t mode, uint32_t time)
*   @brief 切换工作模式
*   @param[in] TCFlag 遥控标志，地面遥控修改姿控时，该值为0XFF，此时不使用姿控建议模式
*/
uint8_t LOS_AOCS_ChangeMode()
{
//    static uint16_t lastmode = Damping;
//    static uint8_t modecnt = 0;
//    static uint32_t exitcnt = 0; //安全模式退出计数
//    static uint8_t tccnt = 0;
//
//    if (MODE_AOCS.AM_TCFLAG == 0xFF)  //如果有地面遥控,遥控切换模式的加断电序列，在LOS_TC.c中实现
//    {
//        MODE_AOCS.mode = MODE_AOCS.TCmode;
//
//        //如果是任务模式，由卫星自主进行模式切换,durtime成为姿控的输入参数
//        if (MODE_AOCS.mode == Command || MODE_AOCS.mode == CamTarget || MODE_AOCS.mode == CamGeo || MODE_AOCS.mode == CMOSTarget || MODE_AOCS.mode == CMOSGeo || MODE_AOCS.mode == XHelicalTarget || MODE_AOCS.mode == XHelicalGeo || MODE_AOCS.mode == XMicroTarget || MODE_AOCS.mode == XMicroGeo)
//        {
//            tccnt++;
//            if (tccnt > 10)
//            {
//                MODE_AOCS.AM_TCFLAG = 0;
//                tccnt = 0;
//            }
//        }
//
//        if ((MODE_AOCS.starttime + MODE_AOCS.durtime) <= LOS_Time_SecFromBoot)
//        {
//            MODE_AOCS.AM_TCFLAG = 0;
//        }
//    }
//    else
//    {
//        MODE_AOCS.mode = aocs_g_output_struct.Mode_Request;
//        if (MODE_AOCS.mode != lastmode)
//        {
//            if (modecnt < 20) //过滤突变
//            {
//                modecnt++;
//                MODE_AOCS.mode = lastmode;
//            }
//            else
//            {
//                modecnt = 0;
//                LOS_FP_EnterNewModeSwitch(MODE_AOCS.mode);  //模式切换，进行相应的加断电操作
//            }
//        }
//        else
//        {
//            modecnt = 0;
//        }
//    }
//    lastmode = MODE_AOCS.mode; //记录一下这次的模式
//    LOS_ModeAcsIn = MODE_AOCS.mode;
}

/** @fn void LOS_AOCS_ForceFailNorm(uint8_t nID)
*   @brief 姿控单机强制故障
*   @param[in] nID 单机nID
*   @param[in] sta 状态 0x55：强制故障 0xAA：强制正常 0xCC：星上自主判断
*/
void LOS_AOCS_ForceFailNorm(uint8_t nID, uint8_t sta)
{
    switch (nID)
    {

//        case nID_GNSS:
//        aocs_g_input_struct.GNSS_FlagM = sta;
//        break;
//
//        case nID_WheelX:
//        aocs_g_input_struct.RW_FlagM[0] = sta;
//        break;
//
//        case nID_WheelY:
//        aocs_g_input_struct.RW_FlagM[1] = sta;
//        break;
//
//        case nID_WheelZ:
//        aocs_g_input_struct.RW_FlagM[2] = sta;
//        break;
//
//        case nID_WheelS:
//        aocs_g_input_struct.RW_FlagM[3] = sta;
//        break;
//
//        case nID_StarSensorY:
//        aocs_g_input_struct.ST_FlagM[0] = sta;
//        break;
//
//        case nID_StarSensorZ:
//        aocs_g_input_struct.ST_FlagM[1] = sta;
//        break;
//
//        case nID_SunSensor:
//        aocs_g_input_struct.FSS_FlagM[0] = sta;
//        break;
//
//        case nID_YH50:
//        aocs_g_input_struct.GYRO_FlagM[0] = sta;
//        break;
//
//        case nID_MagMe:
//        aocs_g_input_struct.MGM_FlagM[0] = sta;
//        break;
//
//        case nID_MEMSDyn:
//        aocs_g_input_struct.MEMS_FlagM[0] = sta;
//        break;

        default:

    }
}
